﻿@model Xms.Web.Models.EditRoleModel

<div class="row">
    <div class="col-sm-2" id="myScrollspy">
        <div class="list-group" id="myNav">
            <a href="#section-1" class="active list-group-item" data-target="#section-1">@app.T["role"] <em class="pull-right glyphicon glyphicon glyphicon-chevron-right"></em></a>
            @if (Model.RoleId.HasValue)
            {
                <a href="#section-2" class="list-group-item" data-target="#section-2">@app.T["user"] <em class="pull-right glyphicon glyphicon glyphicon-chevron-right"></em></a>
            }
        </div>
    </div>
    <div class="col-sm-10" id="scroll-body">
        <div id="section-1" class="panel panel-default">
            <div class="panel-heading">
                <h3 class="panel-title">
                    <a data-toggle="collapse"
                       href="#collapseTwo">
                        <strong>@app.PageTitle</strong>
                    </a>
                </h3>
            </div>
            <div id="collapseTwo" class="panel-collapse collapse in">
                <div class="panel-body">
                    <form id="editform" class="form-horizontal" data-jsonajax="true" data-istip="true" action="/@(app.OrganizationUniqueName)/api/role" method="post">
                        @Html.AntiForgeryToken()
                        @Html.HiddenFor(x => x.RoleId)
                        <div class="form-group col-sm-12">
                            <label class="col-sm-2 control-label" for="Name">@app.T["name"]</label>
                            <div class="col-sm-10">
                                @Html.TextBoxFor(x => x.Name, new { @class = "form-control required" })
                            </div>
                        </div>
                        <div class="form-group col-sm-12">
                            <label class="col-sm-2 control-label" for="State">@app.T["statecode"]</label>
                            <div class="col-sm-10">
                                <label class="checkbox-inline">
                                    @Html.RadioButtonFor(x => x.State, Xms.Core.RecordState.Enabled, new { @class = "required" }) @app.T["enabled"]
                                </label>
                                <label class="checkbox-inline">
                                    @Html.RadioButtonFor(x => x.State, Xms.Core.RecordState.Disabled, new { @class = "required" }) @app.T["disabled"]
                                </label>
                            </div>
                        </div>
                        <div class="form-group col-sm-12">
                            <label class="col-sm-2 control-label" for="Description">@app.T["description"]</label>
                            <div class="col-sm-10">
                                @Html.TextAreaFor(x => x.Description, new { @class = "form-control", @rows = "3" })
                            </div>
                        </div>
                        <div class="form-group col-sm-12 text-center" id="form-buttons">
                            <button type="submit" class="btn btn-primary"><span class="glyphicon glyphicon-saved"></span> @app.T["save"]</button>
                            <button type="reset" class="btn btn-default"><span class="glyphicon glyphicon-refresh"></span> @app.T["reset"]</button>
                        </div>
                    </form>
                </div>
            </div>
        </div>
        <div id="section-2" class="hide" data-url="@("/"+app.OrganizationUniqueName)/role/usersinrole?roleid=@Model.RoleId">
        </div>
    </div>
</div>
@section Scripts {
    <script src="/content/js/jquery.form.js?v=@app.PlatformSettings.VersionNumber"></script>
    <script src="/content/js/jquery-validate/jquery.validate.min.js?v=@app.PlatformSettings.VersionNumber"></script>
    <script src="/content/js/jquery-validate/localization/messages_zh.min.js?v=@app.PlatformSettings.VersionNumber"></script>
    <script>
        $(function () {
            $("#myNav").affix({
                offset: {
                    top: 125
                }
            });
            //表单验证
            Xms.Web.Form($("#editform"));
            //
            $('#myNav').on('click', 'a', function (e) {
                var target = $($(this).attr('data-target'));
                var dataUrl = target.attr('data-url');
                $(this).siblings("a").removeClass("active").end().addClass("active");
                if (dataUrl) {
                    location.href = dataUrl;
                    //target.html('<iframe frameborder="0" src="'+dataUrl+'" width="100%" height="600px"></iframe>');
                    //Xms.Web.LoadPage(dataUrl, null, function (data) {
                    //    target.html($(data).find('#gridview'));
                    //});
                }
                $('#scroll-body > div').addClass('hide');
                target.removeClass('hide');
            });
        });
    </script>
}